-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sourceInputCompletionHook: init #104225
sourceInputCompletionHook: init #104225
Conversation
Looks like #103501 is related? |
definitely looks related, but need to verify if the completions actually work. For stdenv, there's really no need to add shell completion, so I would be suprised if it was sourcing shell completion for normal nix builds. |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/setup-bash-completion-when-running-under-nix-shell-on-macosx/5216/6 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/shell-nix-load-completions/8803/15 |
One thing of note, is that the other PR affects how |
I will have to revisit this for fish, as it's not compatible syntax and zsh doesn't like my associative arrays |
@@ -161,6 +161,8 @@ in | |||
deps = [ innoextract file-rename ]; } | |||
../build-support/setup-hooks/gog-unpack.sh; | |||
|
|||
sourceInputCompletionHook = callPackage ../shells/hooks/sourceInputCompletionHook { }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicitly state ShellHook
?
exit 0 | ||
esac |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit 0 | |
esac | |
exit 0 | |
;; | |
esac |
What about |
local completionDir=$input/$completionPath | ||
if [ -d $completionDir ]; then | ||
for script in $(@findutils@/bin/find $completionDir -type f); do | ||
. $script |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bash completions should be loaded lazily. This can be achieved with XDG_DATA_DIRS
via #103501 or if that's too radical, a shell hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I'm thinking of closing this in favor of #103501 . Made this PR before I was aware of it's existence
I'm likely to close this in favor of #103501 . The other PR encourages better behavior by having individuals listing their dependencies in the appropriate |
on master:
|
I may open this back up again, as fish and zsh still don't have a good way to load completions. |
@jonringer yes please! |
Anything I can do to help revive this? |
The existing and lazy solution already works for bash and fish. We can do let pkgs = import ~/nixpkgs {}; in
pkgs.mkShell {
packages = [ pkgs.hci pkgs.fish pkgs.zsh ];
} and then Zsh doesn't seem to work, but that could be for any reason, considering how sensitive scripts tend to be to their broader environment. I'm not a zsh user, so that doesn't help either. I think the goal should be to get this to work in zsh, without introducing a worse architecture just for one shell. |
Thanks @roberth! I’ll try this out. |
I came upon this PR searching for some way to troubleshoot what's going on with completions in my shells, namely bash and zsh. What I get right now is |
Motivation for this change
It's been a recurrent theme that there's some pain with
nix-shell
and bringing in some tools, only to have shell completion not work without adding additional code toshellHook
. This solves that! (at least for bash)This hasn't been tested with zsh or fish, as running
nix-shell
even with those shells will drop me into a bash shell.If this does get added, may have it added to
mkShell
by default, as that's likely intended user behavior.Also, I don't feel strongly about the name, if anyone can come up with a better name, I'll gladly change it.
example scenario:
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)